package com.lfy.util;

import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
public class SpringUtil  implements ApplicationContextAware {

    public static ApplicationContext applicationContext;



    public static Object getBean(String beanName){
        return applicationContext.getBean(beanName);
    }
    public static <T>T getBean(Class<T> clazz){
         return applicationContext.getBean(clazz);
    }



    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {

        SpringUtil.applicationContext = applicationContext;
        System.out.println("Aware"+SpringUtil.applicationContext);

    }
}
